#include <stdio.h>
#include <windows.h>
#include <iostream>
#include <chrono>
#include <stdlib.h>
#include <ctime>
using namespace std;

string getWeekdayName(int wday) {
	const string weekdayNames[] = {
		"日", "一", "二", "三",
		"四", "五", "六"
	};
	return weekdayNames[wday];
}
int getWeekday(int wday) {
	const int weekdayNames[] = {
		7, 1, 2, 3, 4, 5, 6
	};
	return weekdayNames[wday];
}

int year ;
int month ;
int day ;
int hour ;
int minute ;
int second ;
int weekday ;

void times() {
	// 获取当前系统时间
	auto now = chrono::system_clock::now();

	// 转换为time_t类型
	time_t now_time = chrono::system_clock::to_time_t(now);

	// 转换为本地时间
	tm* local_time = localtime(&now_time);

	// 提取各时间成分
	year = local_time->tm_year + 1900;  // 年份从1900开始
	month = local_time->tm_mon + 1;     // 月份0-11
	day = local_time->tm_mday;          // 日
	hour = local_time->tm_hour;         // 时
	minute = local_time->tm_min;        // 分
	second = local_time->tm_sec;        // 秒
	weekday = local_time->tm_wday;      // 星期几(0-6, 0=Sunday)


}
// 自定义颜色函数
void color(short x) {
	if (x >= 0 && x <= 15) {
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), x);
	} else {
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7); // 默认白色
	}
}
int isclass() {
	if (hour == 8) {
		if (minute < 45) {
			return 1;
		} else if (minute > 54) {
			return 2;
		}
	} else if (hour == 9) {
		if (minute < 40) return 2;
	} else if (hour == 10) {
		if (minute > 9 && minute < 55) {
			return 3;
		}
	} else if (hour == 11) {
		if (minute > 4 && minute < 52) {
			return 4;
		}
	} else if (hour == 14) {
		if (minute < 45) {
			return 5;
		} else if (minute > 54) {
			return 6;
		}
	} else if (hour == 15) {
		if (minute < 40) {
			return 6;
		} else if (minute > 49) {
			return 7;
		}
	} else if (hour == 16) {
		if (minute < 35) {
			return 7;
		} else if (minute > 44) {
			return 8;
		}
	} else if (hour == 17) {
		if (minute < 35) return 8;
	}
	return 0;
}

int main() {
	int table[6][9];
	while (1) {
		freopen("class.txt", "r", stdin);
		times();
		int mi = minute;
		for (int i = 1; i <= 8; i++) {
			for (int j = 1; j <= 5; j++) {
				cin >> table[j][i];
			}
		}
		for (int i = 1; i <= 8; i++) {
			if (i == 1) {
				color(3);
				cout << "                 课 程 表\n        ";
				const string names[] {
					"日", "一", "二", "三", "四", "五"
				};
				for (int k = 1; k <= 5; k++) {
					if (weekday == k) {
						color(2);
					} else {
						color(6);
					}
					cout << " 星期" << names[k];
				}
				cout << endl;
			}
			const string ch[] {
				"零", "一", "二", "三", "四", "五", "六", "七", "八", "九"
			};
			if (isclass() == i) {
				color(2);
			} else {
				color(6);
			}
			cout << "第" << ch[i] << "节  ";
			for (int j = 1; j <= 5; j++) {
				cout << " ";
				string clas[] {
					"语文", "数学", "英语", "物理", "化学", "生物", "地理", "历史", "政治", "体育", "音乐", "美术", "心理", "信息", "自习", "校本", "班会", "社团", "锻炼", "其他"
				};
				color(14);
				if (weekday == j && isclass() == i) color(10);
				cout << clas[table[j][i]] << "  ";
			}
			cout << endl;
			if (i == 4) {color(6);
				cout << "                  午  休\n";
			}
			if (i == 8) {color(6);
							cout << "                 晚 自 习\n";
						}
		}

		cout << "\n   当前时间：" << year << "年 " << month << "月 " << day << "日  " << hour << "时 " << minute << "分";
		for (;;) {
			times();
			if (mi != minute) {
				system("cls");
				break;
			}
		}
	}
}
